package jh.model

import android.util.Log
import java.util.Calendar
import java.util.Date

import jh.utils.XDateUtils
import java.io.Serializable

class CModel :Serializable{

    var id: Int = 0
    var uid: Int = 0
    var likeNumber: Int = 0
    var gradeIntegel: Int = 0
    var gradeCode: Int = 0
    var nickName: String? = null
    var gradeName: String? = null
        get() {


            when (gradeCode) {
                1 -> return "普通会员"
                2 -> return "青铜会员"
                3 -> return "白银会员"
                4 -> return "黄金会员"
                5 -> return "铂金会员"
                6 -> return "钻石会员"
                7 -> return "皇冠会员"
                8 -> return "计划大神"
                else -> return ""
            }
        }
    var gradeUrl: String? = null
    var title: String? = null
    var content: String? = null
    var lotteryCategoryName: String? = null
    var photo: String? = null
    var createTime: String? = null
        get() {

            val date = XDateUtils.string2Date(field, "yyyy-MM-dd HH:mm:ss")

            val currentCal = Calendar.getInstance()
            val currentDate = Date()
            currentCal.time = currentDate   //当前时间

            val toCal = Calendar.getInstance()    //服务器返回对应的评论时间
            toCal.time = date


            return if (XDateUtils.isThisYear(date)) {
                if (XDateUtils.isYesterday(date)) {
                    "昨天 " + XDateUtils.date2String(date, "HH:mm")
                } else if (XDateUtils.isSameDay(field, "yyyy-MM-dd HH:mm:ss")) {
                    val cacHour=currentCal.get(Calendar.HOUR) - toCal.get(Calendar.HOUR)//计算相差几小时
                    val cacMin: Long= (currentCal.timeInMillis - toCal.timeInMillis) / (1000 * 60)//2者的分钟数值
                    Log.e("wewef","时 $cacHour+++++  分 $cacMin")
                    if (cacMin > 59) {
//                        XDateUtils.date2String(date, "HH") + "小时前"
                        cacHour.toString() + "小时前"
                    } else if (cacMin in 2..59) {
//                        XDateUtils.date2String(date, "mm") + "分钟前"
                        cacMin.toString() + "分钟前"
                    } else {
                        "刚刚"
                    }
                } else {
                    XDateUtils.date2String(date, "MM-dd HH:mm")
                }

            } else {
                XDateUtils.date2String(date, "yyyy-MM-dd")
            }

        }
    var isDz: Int = 0
    var count: Int = 0   //评论条数
    var ccId: Int = -1   //帖子ID
    var detailId: String? = ""   //回复的帖子的ID
    var replyId: Int = 0   //ID
    var status:String?=null
    var imgs : String? = null   //交流圈九宫格图片 url
    var mContent:String?=null   //组装的回复内容
}
